<title>设置系统配置</title>
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>设置系统配置</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设置系统配置</div>

                <div class="layui-card-body">
                    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list"
                        style="padding: 20px 30px 0 0;">

                        <blockquote class="layui-elem-quote">
                            <script type='text/html' template>
                            当前选中组织：{{decodeURI(layui.router().search.GroupName)}}
                        </script>
                        </blockquote>


                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">客服电话</label>
                                <div class="layui-input-block">
                                    <input type="tel" name="TellPhone" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">采购热线</label>
                                <div class="layui-input-block">
                                    <input type="tel" name="BuyTellPhone" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">Logo</label>
                                <div class='layui-input-inline'>
                                    <script type='text/html' template lay-done='layui.data.setUpload(d);'>
                                    <input type='text' name='LogoImg' id='LogoImg'  placeholder='请上传图片' autocomplete='off' class='layui-input'>
                                </script>
                                </div>

                                <div class='layui-input-inline layui-btn-container' style='width: auto;'>
                                    <button type='button' class='layui-btn layui-btn-primary' id='Photo_UploadBtn'>
                                        <i class='layui-icon'>&#xe67c;</i>上传图片
                                    </button>
                                    <button class='layui-btn layui-btn-primary'
                                        layadmin-event='Photo_UploadImg'>查看图片</button>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">经理设置</label>
                                <div class="layui-input-inline">
                                    <div class='layui-input-inline'>
                                        <!-- <script type='text/html' template> -->
                                        <select name="AccountManager" xm-select="AccountManager" xm-select-radio=""
                                            xm-select-search="" xm-select-skin="default">
                                            <option value=""></option>
                                        </select>
                                        <!-- </script> -->
                                    </div>
                                </div>
                                <div class="layui-form-mid layui-word-aux">设置每个单位的客户经理</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">商品审核人</label>
                                <div class="layui-input-inline">
                                    <div class='layui-input-inline'>
                                        <!-- <script type='text/html' template> -->
                                        <select name="ReviewManager" xm-select="ReviewManager" xm-select-search=""
                                            xm-select-skin="default">
                                            <option value=""></option>
                                        </select>
                                        <!-- </script> -->
                                    </div>
                                </div>
                                <div class="layui-form-mid layui-word-aux">设置单位商品上架审核的人员(选中组织下的人员)</div>
                            </div>
                        </div>


                        <div class="layui-form-item">
     
                                <label class="layui-form-label">提醒方式</label>
                                <div class="layui-input-inline">
                                    <div class='layui-input-inline'>
                                        <!-- <script type='text/html' template> -->
                                        <select name="RemindType" xm-select="RemindType" xm-select-search=""
                                            xm-select-skin="default">
                                            <option value=""></option>
                                        </select>
                                        <!-- </script> -->
                                    </div>
                                </div>
                                <div class="layui-form-mid layui-word-aux">设置客户经理的提醒方式</div>
                         
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">订单提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="OrderRemind" lay-skin="switch" lay-filter="switchTest"
                                    lay-text="开启|关闭">
                            </div>
                            <div class="layui-form-mid layui-word-aux">客户经理订单推送是否开启</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">预定订单提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="PreOrderRemind" lay-skin="switch" lay-filter="switchTest"
                                    lay-text="开启|关闭">
                            </div>
                            <div class="layui-form-mid layui-word-aux">客户经理预定订单推送</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">售后提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="AfterSaleRemind" lay-skin="switch" lay-filter="switchTest"
                                    lay-text="开启|关闭">
                            </div>
                            <div class="layui-form-mid layui-word-aux">客户经理售后提醒是否开启</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">配送提醒</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="LogisticsinfoRemind" lay-skin="switch"
                                    lay-filter="switchTest" lay-text="开启|关闭">
                            </div>
                            <div class="layui-form-mid layui-word-aux">客户经理配送提醒是否开启</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">库存策略</label>
                            <div class="layui-input-inline">
                                <input type="checkbox" name="ZeroStock" lay-skin="switch" lay-filter="switchTest"
                                    lay-text="能|不能">
                            </div>
                            <div class="layui-form-mid layui-word-aux">库存为0是否能继续销售</div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-form-item">
                                <label class="layui-form-label">上架弘正审核</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="ShelfSupplierReview" lay-skin="switch"
                                        lay-filter="switchTest" lay-text="开启|关闭">
                                </div>
                                <div class="layui-form-mid layui-word-aux">商品上架是否需弘正审核</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">上架单位审核</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="ShelfHospitalReview" lay-skin="switch"
                                        lay-filter="switchTest" lay-text="开启|关闭">
                                </div>
                                <div class="layui-form-mid layui-word-aux">商品上架是否单位需要审核</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">预购单审核</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="PreOrderReview" lay-skin="switch"
                                        lay-filter="switchTest" lay-text="开启|关闭">
                                </div>
                                <div class="layui-form-mid layui-word-aux">是否开通预购单审核</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">订单审核</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="OrderReview" lay-skin="switch" lay-filter="switchTest"
                                        lay-text="开启|关闭">
                                </div>
                                <div class="layui-form-mid layui-word-aux">是否开通订单审核</div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">配送周期说明</label>
                                <div class="layui-input-block">
                                    <textarea name='DeliveryCycle' id='DeliveryCycle' lay-verify="required"
                                        placeholder="请填写配送周期" class="layui-textarea"></textarea>
                                </div>
                                <!-- <div class="layui-input-inline">
                                    <input type='text' name='DeliveryCycle' id='DeliveryCycle' placeholder='请填写配送周期'
                                        autocomplete='off' class='layui-input'>
                                </div> -->
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">是否开启预算</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="isBudgetAble" lay-skin="switch" lay-filter="switchTest"
                                        lay-text="开启|关闭">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">预算类型</label>
                                <div class="layui-input-inline">
                                    <select name='BudgetType'>
                                        <option value=''>请选择</option>
                                        <option value='0'>年</option>
                                        <option value='1'>月</option>
                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="提交"
                                    class="layui-btn">
                            </div>
                            <div class="layui-input-inline">
                                <button class="layui-btn" lay-submit lay-filter="set_website"
                                    onclick="javascript:window.location.href = '#/admin/Portal_Group/'">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <script>
        layui.use(['form', 'admin', 'formSelects'], function () {
            var form = layui.form;//required（必填项）phone（手机号）email（邮箱）url（网址）number（数字）date（日期）identity（身份证） 自定义值
            var $ = layui.$;
            admin = layui.admin;
            var formSelects = layui.formSelects;

            formSelects.config('AccountManager', {
                keyName: 'UserID',            //自定义返回数据中name的key, 默认 name
                keyVal: 'PID',            //自定义返回数据中value的key, 默认 value
            });

            formSelects.config('ReviewManager', {
                keyName: 'UserID',            //自定义返回数据中name的key, 默认 name
                keyVal: 'PID',            //自定义返回数据中value的key, 默认 value
            });

            formSelects.config('RemindType', {
                keyName: 'Text',            //自定义返回数据中name的key, 默认 name
                keyVal: 'PID',            //自定义返回数据中value的key, 默认 value
            });


            layui.formSelects.data('RemindType',
                'local',
                {
                    arr: [{ 'Text': '微信', 'PID': '1' }, { 'Text': '短信', 'PID': '2' }],//要把自己的这个节点去掉
                    linkeage: false,
                    linkageWidth: 140
                });

            form.on('submit(layuiadmin-app-form-submit)', function (data) {
                //添加进去
                admin.req({
                    url: layui.setter.APIUrl + '/admin/configMgr/updateorAddSysConfig' //实际使用请改成服务端真实接口
                    , data: { "configstr": JSON.stringify(data.field), "groupId": layui.router().search.GroupId }
                    , type: "post"
                    , done: function (res) {
                        layer.msg('成功');
                        window.location.href = '#/admin/Portal_Group/'
                        // layer.msg(JSON.stringify(data.field));
                        // return false;
                    }
                });
            });

            //首先获取到组织的id
            admin.req({
                url: layui.setter.APIUrl + '/admin/configMgr/getGroupSysConfig' //实际使用请改成服务端真实接口
                , data: { "groupId": layui.router().search.GroupId }
                , type: "post"
                , done: function (res) {
                    //设置值
                    form.val("layuiadmin-app-form-list", res.Data.model);

                    layui.formSelects.data('AccountManager',
                        'local',
                        {
                            arr: res.Data.userdata, //要把自己的这个节点去掉
                            linkeage: false,
                            linkageWidth: 140
                        });
                    if (res.Data.model.AccountManager) {
                        if (res.Data.model.AccountManager.indexOf(',') == -1) {
                            layui.formSelects.value('AccountManager', [res.Data.model.AccountManager]);
                        } else {
                            layui.formSelects.value('AccountManager', res.Data.model.AccountManager.split(','));
                        }
                    }

                    if (res.Data.model.RemindType) {
                        if (res.Data.model.RemindType.indexOf(',') == -1) {
                            layui.formSelects.value('RemindType', [res.Data.model.RemindType]);
                        } else {
                            layui.formSelects.value('RemindType', res.Data.model.RemindType.split(','));
                        }
                    }

                    layui.formSelects.data('ReviewManager',
                        'local',
                        {
                            arr: res.Data.ReviewManager, //要把自己的这个节点去掉
                            linkeage: false,
                            linkageWidth: 140
                        });

                    if (res.Data.model.ReviewManager) {
                        if (res.Data.model.ReviewManager.indexOf(',') == -1) {
                            layui.formSelects.value('ReviewManager', [res.Data.model.ReviewManager]);
                        } else {
                            layui.formSelects.value('ReviewManager', res.Data.model.ReviewManager.split(','));
                        }
                    }


                }
            });

            form.render();

        });



        layui.data.setUpload = function (d) {
            layui.use(['upload', 'admin'], function () {
                var $ = layui.$,
                    upload = layui.upload,
                    admin = layui.admin;


                //上传头像
                var Photo_UploadSrc = $('#LogoImg');
                upload.render({
                    url: '/WebAPI/file/uploadImg?access_token=' + layui.data('layuiAdmin').access_token
                    , elem: '#Photo_UploadBtn'
                    , accept: 'images'
                    , method: 'get'
                    , multiple: true
                    , acceptMime: 'image/*'
                    , done: function (res) {
                        if (res.ResultCode == 0) {
                            Photo_UploadSrc.val(res.Data.src);
                            layer.msg('上传成功');
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                });

                //查看图片
                admin.events.Photo_UploadImg = function (othis) {
                    var src = Photo_UploadSrc.val();
                    layer.photos({
                        photos: {
                            "title": "查看头像", //相册标题
                            "data": [{
                                "src": src //原图地址
                            }]
                        }
                        , shade: 0.01
                        , closeBtn: 1
                        , anim: 5
                    });
                };

            });
        }

    </script>